package com.ruoyi.web.controller.mall.mallService.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.mallService.domain.MallService;
import com.ruoyi.web.controller.mall.mallService.service.IMallServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商城关于我们Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/mallService")
public class MallServiceController extends BaseController
{
    private String prefix = "mall/mallService";

    @Autowired
    private IMallServiceService mallServiceService;

//    @RequiresPermissions("mall:mallService:view")
    @GetMapping()
    public String mallService()
    {
        return prefix + "/mallService";
    }

    /**
     * 查询商城关于我们列表
     */
//    @RequiresPermissions("mall:mallService:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MallService mallService)
    {
        startPage();
        List<MallService> list = mallServiceService.selectMallServiceList(mallService);
        return getDataTable(list);
    }

    /**
     * 导出商城关于我们列表
     */
//    @RequiresPermissions("mall:mallService:export")
    @Log(title = "商城关于我们", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MallService mallService)
    {
        List<MallService> list = mallServiceService.selectMallServiceList(mallService);
        ExcelUtil<MallService> util = new ExcelUtil<MallService>(MallService.class);
        return util.exportExcel(list, "mallService");
    }

    /**
     * 新增商城关于我们
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商城关于我们
     */
//    @RequiresPermissions("mall:mallService:add")
    @Log(title = "商城关于我们", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MallService mallService)
    {
        return toAjax(mallServiceService.insertMallService(mallService));
    }

    /**
     * 修改商城关于我们
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        MallService mallService = mallServiceService.selectMallServiceById(id);
        mmap.put("mallService", mallService);
        return prefix + "/edit";
    }

    /**
     * 修改保存商城关于我们
     */
//    @RequiresPermissions("mall:mallService:edit")
    @Log(title = "商城关于我们", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MallService mallService)
    {
        return toAjax(mallServiceService.updateMallService(mallService));
    }

    /**
     * 删除商城关于我们
     */
//    @RequiresPermissions("mall:mallService:remove")
    @Log(title = "商城关于我们", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(mallServiceService.deleteMallServiceByIds(ids));
    }
}
